<?php

	//detail, url
	$appkey = isset($_GET['23575466']) ? $_GET['23575466'] : '23575466';
	$pid = isset($_GET['pid']) ? $_GET['pid'] : 'mm_115158616_13830833_55676381';
	$type = isset($_GET['type']) ? $_GET['type'] : 'detail';
	$item_id = isset($_GET['item_id']) ? $_GET['item_id'] : '';
	$url = isset($_GET['url']) ? $_GET['url'] : '';
	$quan_id = isset($_GET['quan_id']) ? $_GET['quan_id'] : '';
	$isv_code = isset($_GET['isv_code']) ? $_GET['isv_code'] : 'zbb';
	
?>
<!DOCTYPE html>
<html>
 <head> 
  <meta charset="utf-8" /> 
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> 
  <script src="http://h5.m.taobao.com/js/src/jquery/jquery-2.1.4.min.js?v=990836632_84344"></script> 
 </head> 
 <body>
 <script src="http://g.alicdn.com/mtb/lib-applink/0.3.2/??callApp.js,linksdk.js?v=3654745502_22304"></script> 
	<script>
		var that = this;
		var appLink = BCSDK_AppLink.init({
			appkey: "<?php echo $appkey ?>",
			linkKey: "TB",
			openApp: true,
			backURL: "tbopen<?php echo $appkey ?>://",
			isNeedDownload: true,
			isDefaultRedirect: false,
			timeout: 2000,
			params:{
				pid: "<?php echo $pid?>",
				isv_code: "<?php echo $isv_code?>"
			}
		});
		console.log("appLink:", appLink);
		function goDetail(item_id) {
			appLink.goDetail({
				linkKey: "TB",
				itemId: item_id,
				params: {
					pid: "<?php echo $pid?>",
					isv_code: "<?php echo $isv_code?>"
				}
			})
		}
		function gotoUrl(url) {
			appLink.gotoUrl({
				linkKey: "TB",
				url: url,
				packageName: "test_packageName",
				params: {
					scm: "test_scm",
					pvid: "test_pvid",
					pid: "<?php echo $pid?>",
					isv_code: "<?php echo $isv_code?>"
				}
			})
		}; 
		
		<?php 
			switch ($type) {
				case 'detail':
					echo "goDetail('{$item_id}')";
				break;
				
				case 'url':
					$url = urldecode($url);
					echo "gotoUrl('{$url}')";
				break;
				
				case 'quan':
					$url = "http://uland.taobao.com/coupon/edetail?activityId={$quan_id}&pid={$pid}&itemId={$item_id}&isv_code={isv_code}&dx=1";
					echo "gotoUrl('{$url}')";
				break;
			}
		?>
	</script> 
</body>
</html>